<template>
    <div class="contentmain">
        <el-row>
            <el-col :span="24">
                <el-form :inline="true" :model="formInline" class="demo-form-inline">
                    <el-form-item>
                        <el-input v-model="serid" placeholder="服务编号"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-date-picker
                            v-model="value1"
                            type="datetime"
                            placeholder="开始时间">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-date-picker
                            v-model="value2"
                            type="datetime"
                            placeholder="结束时间">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit">查询</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
        <!-- 查询 -->
        <el-row>
            <el-col :span="12" :offset="6">
                <div class="box">
                    金额:{{price}}
                </div>
            </el-col>
        </el-row>
        <!-- 显示 -->
    </div>
</template>
<script>
import moment from 'moment'
export default {
    data(){
        return{
            formInline:{},
            price:'无',
            value1:'',
            value2:'',
            serid:''
        }
    },
    methods:{
        onSubmit(){//查询项
            var _this=this
            var pp=new URLSearchParams()
            if(!this.serid){
                this.$message.error('服务编号不能为空')
                return
            }
            pp.append('serviceNum',this.serid)
            if(!this.value1){
                this.$message.error('开始时间不能为空')
                return
            }
            pp.append('startTime',moment(this.value1).format("YYYY-MM-DD HH:mm:ss"))
            if(!this.value1){
                this.$message.error('结束时间不能为空')
                return
            }
            pp.append('endTime',moment(this.value2).format("YYYY-MM-DD HH:mm:ss"))

            axios.get('/aggregate.do',{params:pp}).then((r) => {
                if(r.data.code==200){
                    _this.price=r.data.response.bounty
                }else{
                    if(r.data.message=="not login"&&r.data.code==500){
                        _this.$message.error("访问者,请登录")
                        router.push('/Login');
                        return
                    }
                    _this.$message.error(r.data.message)
                }
            })
        }
    }
}
</script>
<style scoped>
.box{
    width: 100%;
    height: 60px;
    font-size: 24px;
    line-height: 60px;
    border: 1px solid #efefef;
    border-radius: 10px;
    text-align: center;
}
</style>

